package com.qd.core.aspect.operarorlog;

import java.util.Optional;

/**
 * @author: sjk
 */
public class OperatorLogManager {
    private OperatorLogManager() {

    }

    private static final ThreadLocal<OperatorAopLog> OPERATOR_AOP_LOG_THREAD_LOCAL = new ThreadLocal<>();

    public static void setOperatorAopLog(OperatorAopLog data) {
        OPERATOR_AOP_LOG_THREAD_LOCAL.set(data);
    }

    public static OperatorAopLog getOperatorAopLog() {
        return OPERATOR_AOP_LOG_THREAD_LOCAL.get();
    }

    public static void clear() {
        Optional.ofNullable(getOperatorAopLog()).ifPresent(OperatorAopLog::freeData);
        OPERATOR_AOP_LOG_THREAD_LOCAL.remove();
    }

}
